package rs.dalao.syc.index.dao.persist.repository.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import rs.dalao.syc.common.pojo.vo.PageData;
import rs.dalao.syc.common.util.PageInfoToPageDataConverter;
import rs.dalao.syc.index.dao.persist.mapper.VaccineMapper;
import rs.dalao.syc.index.dao.persist.mapper.VideoMapper;
import rs.dalao.syc.index.dao.persist.repository.IVaccineRepository;
import rs.dalao.syc.index.dao.persist.repository.IVideoRepository;
import rs.dalao.syc.index.pojo.vo.VacDetailsVO;
import rs.dalao.syc.index.pojo.vo.VaccineListVO;
import rs.dalao.syc.index.pojo.vo.VideoDetailVO;
import rs.dalao.syc.index.pojo.vo.VideoVO;

import java.util.List;


@Slf4j
@Repository
public class VideoRepositoryImpl implements IVideoRepository {

    @Autowired
    private VideoMapper videoMapper;

    @Override
    public PageData<VideoVO> listVideo(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<VideoVO> list = videoMapper.listVideo();
        PageInfo<VideoVO> pageInfo = new PageInfo<>(list);
        return PageInfoToPageDataConverter.convert(pageInfo);
    }

    @Override
    public VideoDetailVO selectVideoById(Long id){
        return videoMapper.selectVideoById(id);
    }

}
